package com.zlll.winner.controller;

import com.alibaba.fastjson.JSONObject;
import com.zlll.winner.business.model.activity.ActivityApply;
import com.zlll.winner.business.model.activity.ActivityApplyExternal;
import com.zlll.winner.business.model.activity.ActivityManagement;
import com.zlll.winner.business.service.activity.IActivityApplyExternalService;
import com.zlll.winner.business.service.activity.IActivityApplyService;
import com.zlll.winner.business.service.activity.IActivityManagementService;
import com.zlll.winner.business.service.bbs.IBbsPostService;
import com.zlll.winner.business.service.bbs.IBbsSubjectService;
import com.zlll.winner.common.BaseController;
import com.zlll.winner.common.BaseResponseBodyAdvice;
import com.zlll.winner.common.BaseResult;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.http.HttpStatus;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("api/bbs/subject")
@RestController
public class BbsSubjectController extends BaseController {

    @Reference(version = "${dubbo.consumer.version}")
    private IBbsSubjectService subjectService;

    @Reference(version = "${dubbo.consumer.version}")
    private IBbsPostService postService;
    /**
     * 频道话题获取
     * @param params
     * @return
     */
    @PostMapping("info")
    public Object info(@RequestBody JSONObject params){
        String position = params.getString("position");
        String city = params.getString("city");
        Assert.notNull(position,"频道不能为空");
        Object result = subjectService.getSubjectInfoByPosition(position,city);
        return result == null? getEmptyResult(): result;
    }

    @PostMapping("postList")
    public Object postList(@RequestBody JSONObject params){
        Integer pageNo = params.getInteger("pageNo");
        Integer pageSize = params.getInteger("pageSize");
        Long subjectId = params.getLong("subjectId");

        Assert.notNull(pageNo,"pageNo不能为空");
        Assert.notNull(pageSize,"pageSize不能为空");
        Assert.notNull(subjectId,"话题ID不能为空");

        Object result = postService.fetchPostPage(params);
        return result == null? getEmptyResult(): result;
    }

}
